<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>测试webview-test</title>
	</head>
	<body>
		<div style="padding-top: 50px;">
			<button  onclick="play()">play</button>
			<button  onclick="pause()">pause</button>
			<button  onclick="seek()">seek</button>
			<button  onclick="requestFullScreen()">切换到全屏</button>
			<button  onclick="exitFullScreen()">退出全屏</button>
			<button  onclick="stop()">停止播放视频</button>
			<button  onclick="hide()">隐藏视频播放控件</button>
			<button  onclick="show()">显示视频播放控件</button>
			<button  onclick="close()">关闭视频播放控件</button>
			<button  onclick="sendDanmu()">发送弹幕</button>
			<button  onclick="playbackRate()">设置倍速播放</button>
			<button  onclick="getVideoPlayerById()">查找已经创建的VideoPlayer对象</button>
		</div>
		<script>
			document.addEventListener( "plusready", function(){
			  // 扩展API加载完毕，现在可以正常调用扩展API
			  createVideoPlayer();
			}, false );
			var player = null;
			// 创建视频播放控件
			// https://www.w3school.com.cn/i/movie.ogg
			function createVideoPlayer() {
				if(!player){
					player = plus.video.createVideoPlayer('videoplayer', {
						src:'https://www.runoob.com/try/demo_source/movie.mp4',
						top:'200px',
						left:"auto",
						width: '90%',
						height: '200px',
						position: 'static',
						autoplay:true,
						controls:true,
						"enable-danmu":true,
						"danmu-btn":true
					});
					plus.webview.currentWebview().append(player);
				}
			}
			function play(){
				player.play();
			}
			function pause(){
				player.pause();
			}
			function seek(){
				player.seek(100)
			}
			function requestFullScreen(){
				player.requestFullScreen(0)
			}
			function exitFullScreen(){
				player.exitFullScreen()
			}
			function stop(){
				player.stop()
			}
			function hide(){
				player.hide()
			}
			function show(){
				player.show()
			}
			function close(){
				player.close()
			}
			function sendDanmu(){
				player.sendDanmu({text:'要显示的弹幕文本',color:'#FF0000'});
			}
			function playbackRate(){
				player.playbackRate(1.5);
			}
			function getVideoPlayerById(){
				var b = plus.video.getVideoPlayerById('videoplayer');
					if(b){
						console.log('find success!');
						alert('success');
					} else {
						console.log('find failed!');
						alert('failed');
					}
			}
		</script>
	</body>
</html>
